<template>
  <div>
    <el-button type="success" @click="bigoutData">导出excel</el-button>

    <div id="divId">
      <uploader :options="options" class="uploader-example" @file-added="onFileAdded">
<!--        //文件上传的按钮-->
        <uploader-drop>
          <p>将文件放在这里上传</p>
          <uploader-btn>选择上传的文件</uploader-btn>
        </uploader-drop>
<!--        文件上传的进度条-->
        <uploader-list></uploader-list>
      </uploader>
    </div>
  </div>
</template>
<script>
import SparkMD5 from "spark-md5";
export default {
  data() {
    return {
      options: {
        target: 'http://localhost:8888/testuser/bigupload', // 目标上传 URL
        chunkSize: '2048000', //分块大小
        fileParameterName: 'file', //上传文件时文件的参数名，默认file
        maxChunkRetries: 3, //最大自动失败重试上传次数
        testChunks: false, //是否开启服务器分片校验
      }
    }
  },
  created() {

  },
  methods: {
    bigoutData() {
      location = "http://localhost:8888/testuser/baiwanout";
    },
    // 使用spark-md5插件，给每一片生成唯一标识
    onFileAdded(file) {
      const fileReader = new FileReader()
      fileReader.readAsBinaryString(file);
      fileReader.onload = e => {
        const md5 = SparkMD5.hashBinary(e.target.result);
        console.log(md5);
        file.uniqueIdentifier = md5;
      }
    }
  }

}
</script>

<style scoped>

</style>
